-- don_quixote
-- create by shuzy
-- 堂吉诃德效果

return {
    apply = function(source, target, skillId, round, para, extra)
        local effectRound = -1;
        extra = extra or {};
        local lastRound = extra.lastRound;


        if type(lastRound) == "number" then
            effectRound = round + lastRound + 1;
        elseif para[3] > 0 then
            -- 不包括本回合
            effectRound = round + para[3] + 1;
        end

        -- 绝对值效果
        local value1 = para[1];
        local value2 = para[2];

        -- 增加命中动作
        SkillM.getSequence(target):hit(source, target, skillId);

        -- 记录状态
        local condition = {
            ["value1"] = value1,
            ["value2"] = value2,
            ["end_round"]   = effectRound,
        };
        CombatStatusM.applyStatus(source, "don_quixote", condition);

        -- 作用目标
        return { target, };
    end,

    parse = function(desc)
        local arr = string.explode(desc, ",");
        return { tonumber(arr[1]), tonumber(arr[2]), tonumber(arr[3] or -1) };
    end,

    -- 解析技能描述
    parseDesc = function(source, skillId, desc, para)
        -- 1. 威力
        local value1 = para[1];
        local value2 = para[2];

        desc = string.gsub(desc, "{value1}", value1 / 10);
        desc = string.gsub(desc, "{value2}", value2 / 10);
        desc = string.gsub(desc, "{round}", para[3]);

        return desc;
    end,
};
